﻿#ifndef TIANDITUMAPPROVIDER_H
#define TIANDITUMAPPROVIDER_H

#include "MapProvider.h"

static const QString tiandituImg = QStringLiteral("http://%1.tianditu.gov.cn/img_w/"
                                                  "wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&"
                                                  "TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX=%2&TILEROW=%3&TILECOL=%4&tk=%5");

static const QString tiandituCia = QStringLiteral("http://%1.tianditu.gov.cn/cia_w/"
                                                  "wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cia&STYLE=default&"
                                                  "TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX=%2&TILEROW=%3&TILECOL=%4&tk=%5");

static const QString tiandituVec = QStringLiteral("http://%1.tianditu.gov.cn/vec_w/"
                                                  "wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&"
                                                  "TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX=%2&TILEROW=%3&TILECOL=%4&tk=%5");

static const QString tiandituCva = QStringLiteral("http://%1.tianditu.gov.cn/cva_w/"
                                                  "wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&STYLE=default&"
                                                  "TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX=%2&TILEROW=%3&TILECOL=%4&tk=%5");

class TiandituMapProvider : public MapProvider
{
    Q_OBJECT
public:
    TiandituMapProvider(const QString& format, const quint32 averageSize,
                        const QGeoMapType::MapStyle mapType, QObject*parent  = nullptr);
    ~TiandituMapProvider() override = default;

    QNetworkRequest getTileURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;

protected:
    QString _token;
    QString _sld;  // 天地图二级域名 t0~t7
};


/**
 * @brief The TiTiandituImgMapProvider class 天地图 卫星影像图
 */
class TiandituImgMapProvider : public TiandituMapProvider
{
public:
    TiandituImgMapProvider(QObject* parent = nullptr);
    ~TiandituImgMapProvider() override = default;

protected:
    QString _getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;
};


/**
 * @brief The TiTiandituCiaMapProvider class 天地图 影像图标注
 */
class TiandituCiaMapProvider : public TiandituMapProvider
{
public:
    TiandituCiaMapProvider(QObject* parent = nullptr);
    ~TiandituCiaMapProvider() override = default;

protected:
    QString _getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;
};


/**
 * @brief The TiTiandituVecMapProvider class 天地图 矢量底图
 * 不再使用！！
 */
class TiandituVecMapProvider : public TiandituMapProvider
{
public:
    TiandituVecMapProvider(QObject* parent = nullptr);
    ~TiandituVecMapProvider() override = default;

protected:
    QString _getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;
};


/**
 * @brief The TiandituCvaMapProvider class
 * 不再使用！！
 */
class TiandituCvaMapProvider : public TiandituMapProvider
{
public:
    TiandituCvaMapProvider(QObject* parent = nullptr);
    ~TiandituCvaMapProvider() override = default;

protected:
    QString _getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;
};

#endif // TIANDITUMAPPROVIDER_H
